from typing import Optional, List, Dict, Any

from pydantic import BaseModel


class ErrorResponse(BaseModel):
    code: int
    message: str
    detail: Optional[List[Dict[str, Any]]] = None

    class Config:
        schema_extra = {
            "example": {
                "code": 404,
                "message": "Resource not found",
                "detail": [{"loc": ["path", "user_id"], "msg": "用户不存在"}]
            }
        }